package com.gogonow.beetl.chapter2.template;

import java.io.File;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;

import org.beetl.core.Configuration;
import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;
import org.beetl.core.resource.FileResourceLoader;

public class FileTemplate {
	
	public static void main(String[] args) throws Exception{
		String root = System.getProperty("user.dir")+File.separator+"src/main/resources/template";
		FileResourceLoader fileLoader = new FileResourceLoader(root, Charset.forName("UTF-8").name());
		Configuration conf = Configuration.defaultConfiguration();
		GroupTemplate gt = new GroupTemplate(fileLoader, conf);
		Map<String, Object> params = new HashMap<String, Object>();
//		params.put("name", "zhuzl");
//		gt.setSharedVars(params);
		Template template1 = gt.getTemplate("beetl.txt");
		template1.binding("name", "zhuzl1");
		Template template2 = gt.getTemplate("beetl.txt");
		template2.binding("name", "zhuzl2");
		System.out.println(template1.render());
		System.out.println(template2.render());
	}

}
